<template>
	<mescroll-uni class="list" :fixed="false" @init="mescrollInit" :height="'100%'" @scroll="scroll" :down="down"
		@down="downCallback" @up="upCallback">
		<slot></slot>
		<view class="commission-list-container">
			<view class="list-box" :data-status="data.review_status+api" v-for="(data,index) in list" :key="index"
				@click="$emit('goPage',data)">
				<view class="list-box-left">
					<view class="title">
						<view class="content">{{data.content}}</view>
						<view class="price" :style="{
												color:data.profit>=0?'#e5984f':''
											}">{{data.profit}}</view>
					</view>
					<view class="time">
						<view>{{data.create_time}}</view>
						<!-- 当状态不是0 或者 提现记录的时候 显示月 -->
						<view v-if="data.review_status!=0 && api!='getPayslipList'">
							余额（元）：{{data.after}}</view>
					</view>
				</view>
			</view>
		</view>
	</mescroll-uni>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import {
		publicConfig
	} from "@/api";
	export default {
		mixins: [MescrollMixin], // 使用mixin
		props: {
			api: {
				type: String,
				default: 'getUserpriceList'
			},
			params: {
				type: Object,
				default: () => {}
			}
		},
		mounted() {
			this.$emit('getDownCallback', this.downCallback)
		},
		data() {
			return {
				down: {},
				list: [],
			}
		},
		methods: {
			downCallback(e) {
				this.list = []
				this.mescroll.resetUpScroll()
			},
			upCallback(page) {
				this.time = new Date().getTime()
				this.getList(page.num, this.time)
			},
			async getList(page, time) {
				try {
					const {
						data
					} = await publicConfig(this.api, {
						...this.params,
						page

					}, false)
					if (this.time === time) {
						if (page === 1) {
							this.list = []
						}
						this.list = [...this.list, ...data.data]
						const curPageLen = data.data.length
						const totalSize = data.total
						this.mescroll.endBySize(curPageLen, totalSize)
					}
				} catch (e) {
					this.mescroll.endErr()
				}
			},
		}

	}
</script>

<style lang="scss" scoped>
	.commission-list {
		background-color: #FFFFFF;

		&-container {
			box-shadow: 2rpx 4rpx 21rpx 0rpx rgba(51, 51, 51, 0.08);
			border-radius: 10rpx;
			margin: 30rpx;
		}
	}


	.list-box {
		font-family: Alibaba PuHuiTi 2.0;
		font-weight: normal;
		display: flex;
		justify-content: space-between;
		align-items: center;
		flex-wrap: wrap;
		border-bottom: 1px solid #f6f6f6;
		position: relative;

		&-left {
			width: 100%;
			padding: 45rpx 35rpx;

			.title {
				font-size: 33rpx;
				font-family: Alibaba PuHuiTi 2.0;
				color: #333333;
				font-weight: bold;
				margin-bottom: 20rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;

				.content {
					overflow: hidden;
					text-overflow: ellipsis;
					-webkit-line-clamp: 2;
					display: -webkit-box;
					width: 70%;
					-webkit-box-orient: vertical;
				}
			}

			.time {
				font-size: 25rpx;
				color: #999999;
				display: flex;
				justify-content: space-between;
				align-items: center;
			}
		}

		&-item {
			width: 50%
		}

		&[data-status='0getWithdrawList']:before {
			position: absolute;
			bottom: 0;
			right: 0;
			content: '';
			width: 100%;
			height: 100%;
			background: url('/static/image/commission/daishenhe.png');
			z-index: -1;
			background-repeat: no-repeat;
			background-size: contain;
			background-position: center center;
		}
	}
</style>